<template>
    <div class="top">
        <div class="left">
            <span class="btn" @click="$router.push('/home')">首页</span>
        </div>
        <div class="middle">
            <div class="title">智慧可视化大数据展示平台</div>
        </div>
        <div class="right">
            <span class="btn">统计报告</span>
            <span class="time">当前时间：{{ time }}</span>
        </div>
    </div>
</template>

<script setup lang="ts">
import moment from 'moment';
import { useRouter } from 'vue-router';
import { onMounted, onBeforeUnmount, ref } from 'vue'
// 获取路由器对象
let $router = useRouter()

// 获取当前时间
let time = ref(moment().format('YYYY年MM月DD日 HH:mm:ss'))
// 定时器
let timer = ref(0)
// 组件挂载完毕，设置定时器获取时间
onMounted(() => {
    timer.value = setInterval(() => {
        time.value = moment().format('YYYY年MM月DD日 HH:mm:ss')
    }, 1000)
})

onBeforeUnmount(() => {
    clearInterval(timer.value);
})
</script>

<style scoped style="scss">
.top {
    width: 100%;
    height: 40px;
    /* background-color: red; */
    display: flex;
    color: #29fcff;
    font-size: 19px;
    text-align: center;

    .left {
        flex: 1;
        background: url(../images/dataScreen-header-left-bg.png) no-repeat;
        background-size: cover;

        .btn {
            width: 130px;
            height: 40px;
            float: right;
            background: url(../images/dataScreen-header-btn-bg-l.png) no-repeat;
            /* 完全撑开背景至容器大小 */
            background-size: 100% 100%;
            line-height: 40px;
        }
    }

    .middle {
        flex: 2;

        .title {
            width: 100%;
            height: 74px;
            background: url(../images/dataScreen-header-center-bg.png) no-repeat;
            background-size: 100% 100%;
            line-height: 74px;
            font-size: 32px;
        }
    }

    .right {
        flex: 1;
        line-height: 40px;
        background: url(../images/dataScreen-header-right-bg.png) no-repeat;
        background-size: cover;

        .btn {
            height: 40px;
            width: 130px;
            background: url(../images/dataScreen-header-btn-bg-r.png) no-repeat;
            background-size: 100% 100%;
            float: left;
        }

        .time {
            float: right;
            margin-right: 10px;
        }
    }
}</style>